package com.cskaoyan.com.linked;

public class DemoLinked2 {
    public static void main(String[] args) {

        // zs  <--->  ls  <---->  wu  <--->  zl
        DBNode zs = new DBNode("zs");
        DBNode ls = new DBNode("ls");
        DBNode wu = new DBNode("wu");
        DBNode zl = new DBNode("zl");

        zs.next = ls;
        ls.next = wu;
        wu.next = zl;
        //  zs  -->  ls  --> wu  --> zl


        zl.pre = wu;
        wu.pre = ls;
        ls.pre = zs;
        //  zs  <--->  ls  <---->  wu  <--->  zl


        System.out.println(zs);

    }
}

// 双向链表的结点
class  DBNode {

    String value; // 结点的值域
    DBNode pre;   // 结点的前指针域
    DBNode next;  // 结点的后指针域

    public DBNode(String value) {
        this.value = value;
    }

    public DBNode( DBNode pre, String value, DBNode next) {
        this.value = value;
        this.pre = pre;
        this.next = next;
    }

    @Override
    public String toString() {
        return "DBNode{" +
                "value='" + value + '\'' +
//                ", pre=" + pre +
                ", next=" + next +
                '}';
    }
}